package now

import (
	"fmt"
	times "gitee.com/magein/go-utils/time"
	"time"
)

// Unix Get the current timestamp
func Unix() int {
	now := time.Now()
	return int(now.Unix())
}

// Date Get the current date
func Date(parameter ...string) string {

	sp := "-"
	if len(parameter) > 0 {
		sp = parameter[0]
	}

	now := time.Now()

	return fmt.Sprintf("%d%s%s%s%s", now.Year(), sp, times.PadTwoDigit(int(now.Month())), sp, times.PadTwoDigit(now.Day()))
}

// Time Get the current time
func Time(parameter ...string) string {

	sp := ":"
	if len(parameter) > 0 {
		sp = parameter[0]
	}

	now := time.Now()

	return fmt.Sprintf("%s%s%s%s%s", times.PadTwoDigit(now.Hour()), sp, times.PadTwoDigit(now.Minute()), sp, times.PadTwoDigit(now.Second()))
}

// Datetime Get the current date and time
func Datetime() string {
	return Date() + " " + Time()
}
